<?php
$nice = $argv[1];
$start = time();
$count = 0;
$pid = pcntl_fork();

if ($pid==0){
    fprintf(STDOUT,"child process pid=%d,nice=%d\n",posix_getpid(),pcntl_getpriority());
    pcntl_setpriority($nice,getmypid(),PRIO_PROCESS);
    fprintf(STDOUT,"child process pid=%d,nice=%d\n",posix_getpid(),pcntl_getpriority());

    while (1){
        $count++;
        if (time()-$start>5){
            break;
        }
    }
}else{
    fprintf(STDOUT,"parent process pid=%d,nice=%d\n",posix_getpid(),pcntl_getpriority());
    pcntl_setpriority($nice,getmypid(),PRIO_PROCESS);
    fprintf(STDOUT,"child process pid=%d,nice=%d\n",posix_getpid(),pcntl_getpriority());
    while (1){
        $count++;
        if (time()-$start>5){
            break;
        }
    }
}

fprintf(STDOUT,"pid=%d,nice=%d,count=%d\n",posix_getpid(),pcntl_getpriority(),$count);